<div class="menu-node">
    <div class="ui list" *ngIf="workflow">
        <ng-container *ngIf="workflowrun">
            <a class="item" (click)="sendEvent('run')" [class.disabled]="!runnable">
                {{'btn_run' | translate }}
            </a>
            <hr>
        </ng-container>
        <ng-container *ngIf="node && !noderun">
            <a class="item" (click)="sendEvent('pipeline')"
                [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0) || readonly">
                    {{ 'workflow_node_trigger_add' | translate }}
            </a>
            <a class="item" (click)="sendEvent('parent')"
                [class.disabled]="!workflow || workflow.workflow_data.node.id !== node.id ||  (workflow.from_repository && workflow.from_repository.length > 0) || readonly">
                    {{ 'workflow_node_parent' | translate }}
            </a>
            <a class="item" (click)="sendEvent('fork')" [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0)
            || readonly">
                    {{ 'workflow_node_fork_add' | translate }}
            </a>
            <a class="item" (click)="sendEvent('join')" [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0)
           || readonly">
                    {{ 'workflow_node_join_add' | translate }}
            </a>
            <a class="item" (click)="sendEvent('join_link')" [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0)
           || readonly">
                {{ 'workflow_node_join_link' | translate }}
            </a>
            <hr>
            <a class="item" (click)="sendEvent('hook')"
                [class.disabled]="!workflow || !workflow.workflow_data || workflow.workflow_data.node.id !== node.id || (workflow.from_repository && workflow.from_repository.length > 0) || readonly">
                {{ 'workflow_node_hook_add' | translate }}
            </a>
            <a class="item" (click)="sendEvent('outgoinghook')" [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0)
           || readonly">
                    {{ 'workflow_node_outgoing_hook' | translate }}
            </a>
            <hr>
            <a class="item" (click)="sendEvent('edit')">
                    <span *ngIf="readonly">{{ 'workflow_node_menu_edit_ro' | translate }}</span>
                    <span *ngIf="!readonly">{{ 'workflow_node_menu_edit' | translate }}</span>
            </a>
            <ng-container *ngIf="node.type === 'pipeline' && workflow && workflow.pipelines && node && node.context">
                <a class="item"
                    [routerLink]="['/project', project.key, 'pipeline', workflow.pipelines[node.context.pipeline_id].name]"
                    [queryParams]="{workflow: workflow.name}">
                        {{ 'workflow_node_menu_edit_pipeline' | translate }}
                </a>
            </ng-container>
            <hr>
            <a class="item" (click)="sendEvent('delete')" [class.disabled]="(workflow.from_repository && workflow.from_repository.length > 0) || readonly
                || node.id === workflow.workflow_data.node.id">
                    {{ 'btn_delete' | translate }}
            </a>
        </ng-container>
        <ng-container *ngIf="node && noderun">
            <ng-container *ngIf="node.type === 'pipeline'">
                <a class="item" (click)="sendEvent('logs')">
                    {{'btn_logs' | translate }}
                </a>
                <hr>
            </ng-container>
            <a class="item" (click)="sendEvent('edit')">
                    {{ 'workflow_node_menu_edit_ro' | translate }}
            </a>
        </ng-container>
    </div>
</div>
